/****************************************************************************
** @brief
****************************************************************************/

#ifndef OIOVCALLBACK_H
#define OIOVCALLBACK_H

#include <QObject>

#include "../../iov/operation/operation_protocol_data_def.h"

class OiovCallback : public QObject
{
    Q_OBJECT

public:
    explicit OiovCallback(QObject *parent = nullptr);
    ~OiovCallback();

    /*-------------------------------------------------------------------------------*/

    /*
     * 服务端处理结果
     */
    enum ops_service_handle_result {
        OPS_SERVICE_HANDLE_RESULT_SUCCESS = 0x00, //!< 成功
        OPS_SERVICE_HANDLE_RESULT_FAILED,         //!< 失败
    };

    /*
     * 本地端处理结果
     */
    enum ops_local_handle_result {
        OPS_LOCAL_HANDLE_RESULT_FAILED = 0x00, //!< 失败
        OPS_LOCAL_HANDLE_RESULT_SUCCESS,       //!< 成功
    };

    /*
     * 充电桩状态
     */
    enum ops_chargingpile_state {
        OPS_CHARGINGPILE_STATE_OFFLINE = 0x00, //!< 离线
        OPS_CHARGINGPILE_STATE_FAULT,          //!< 故障
        OPS_CHARGINGPILE_STATE_IDLE,           //!< 空闲
        OPS_CHARGINGPILE_STATE_CHARGING,       //!< 充电中
    };

    /*
     * 充电枪状态
     */
    enum ops_charginggun_state {
        OPS_CHARGINGGUN_STATE_NORMAL = 0x00, //!< 正常
        OPS_CHARGINGGUN_STATE_FAULT,         //!< 故障
    };

    /*
     * 充电枪连接状态
     */
    enum ops_gun_connect_state {
        OPS_GUN_CONNECT_STATE_NOT = 0x00, //!< 枪没有连接
        OPS_GUN_CONNECT_STATE_YES,        //!< 枪连接
    };

    /*
     * 启动方式
     */
    enum ops_chargingpile_start_type {
        OPS_CHARGINGPILE_START_TYPE_CARD = 0x01, //!< CARD
        OPS_CHARGINGPILE_START_TYPE_ID,          //!< ID
        OPS_CHARGINGPILE_START_TYPE_VIN,         //!< VIN
    };

    /*
     * 交易标识
     */
    enum ops_transaction_type {
        OPS_TRANSACTION_TYPE_APP = 0x01,     //!< APP
        OPS_TRANSACTION_TYPE_ONCARD = 0x02,  //!< 在线卡
        OPS_TRANSACTION_TYPE_OFFCARD = 0x04, //!< 离线卡
        OPS_TRANSACTION_TYPE_VIN = 0x05,     //!< VIN
        OPS_TRANSACTION_TYPE_HCI = 0x0F,     //!< HCI
    };

    /*
     * 充电完成
     */
    enum dev_stop_charging_code {
        DEV_STOP_CHARGING_CODE_40 = 0x40, //!< 结束充电，APP 远程停止
        DEV_STOP_CHARGING_CODE_41, //!< 结束充电，SOC 达到100%（充满）
        DEV_STOP_CHARGING_CODE_42, //!< DEV_STOP_CHARGING_CODE_42
        DEV_STOP_CHARGING_CODE_43, //!< DEV_STOP_CHARGING_CODE_43
        DEV_STOP_CHARGING_CODE_44, //!< DEV_STOP_CHARGING_CODE_44
        DEV_STOP_CHARGING_CODE_45, //!< 手动停止充电
        DEV_STOP_CHARGING_CODE_46, //!< DEV_STOP_CHARGING_CODE_46
        DEV_STOP_CHARGING_CODE_47, //!< DEV_STOP_CHARGING_CODE_47
        DEV_STOP_CHARGING_CODE_48, //!< DEV_STOP_CHARGING_CODE_48
        DEV_STOP_CHARGING_CODE_49, //!< DEV_STOP_CHARGING_CODE_49
    };

    /*
     * 充电启动失败
     */
    enum dev_start_charging_failed_code {
        DEV_START_CHARGING_FAILED_CODE_4A =
            0x4A,                          //!< DEV_START_CHARGING_FAILED_CODE_4A
        DEV_START_CHARGING_FAILED_CODE_4B, //!< DEV_START_CHARGING_FAILED_CODE_4B
        DEV_START_CHARGING_FAILED_CODE_4C, //!< DEV_START_CHARGING_FAILED_CODE_4C
        DEV_START_CHARGING_FAILED_CODE_4D, //!< DEV_START_CHARGING_FAILED_CODE_4D
        DEV_START_CHARGING_FAILED_CODE_4E, //!< DEV_START_CHARGING_FAILED_CODE_4E
        DEV_START_CHARGING_FAILED_CODE_4F, //!< DEV_START_CHARGING_FAILED_CODE_4F
        DEV_START_CHARGING_FAILED_CODE_50, //!< DEV_START_CHARGING_FAILED_CODE_50
        DEV_START_CHARGING_FAILED_CODE_51, //!< DEV_START_CHARGING_FAILED_CODE_51
        DEV_START_CHARGING_FAILED_CODE_52, //!< DEV_START_CHARGING_FAILED_CODE_52
        DEV_START_CHARGING_FAILED_CODE_53, //!< DEV_START_CHARGING_FAILED_CODE_53
        DEV_START_CHARGING_FAILED_CODE_54, //!< DEV_START_CHARGING_FAILED_CODE_54
        DEV_START_CHARGING_FAILED_CODE_55, //!< DEV_START_CHARGING_FAILED_CODE_55
        DEV_START_CHARGING_FAILED_CODE_56, //!< DEV_START_CHARGING_FAILED_CODE_56
        DEV_START_CHARGING_FAILED_CODE_57, //!< DEV_START_CHARGING_FAILED_CODE_57
        DEV_START_CHARGING_FAILED_CODE_58, //!< DEV_START_CHARGING_FAILED_CODE_58
        DEV_START_CHARGING_FAILED_CODE_59, //!< DEV_START_CHARGING_FAILED_CODE_59
        DEV_START_CHARGING_FAILED_CODE_5A, //!< DEV_START_CHARGING_FAILED_CODE_5A
        DEV_START_CHARGING_FAILED_CODE_5B, //!< DEV_START_CHARGING_FAILED_CODE_5B
        DEV_START_CHARGING_FAILED_CODE_5C, //!< DEV_START_CHARGING_FAILED_CODE_5C
        DEV_START_CHARGING_FAILED_CODE_5D, //!< DEV_START_CHARGING_FAILED_CODE_5D
        DEV_START_CHARGING_FAILED_CODE_5E, //!< DEV_START_CHARGING_FAILED_CODE_5E
        DEV_START_CHARGING_FAILED_CODE_5F, //!< DEV_START_CHARGING_FAILED_CODE_5F
        DEV_START_CHARGING_FAILED_CODE_60, //!< DEV_START_CHARGING_FAILED_CODE_60
        DEV_START_CHARGING_FAILED_CODE_61, //!< DEV_START_CHARGING_FAILED_CODE_61
        DEV_START_CHARGING_FAILED_CODE_62, //!< DEV_START_CHARGING_FAILED_CODE_62
        DEV_START_CHARGING_FAILED_CODE_63, //!< DEV_START_CHARGING_FAILED_CODE_63
        DEV_START_CHARGING_FAILED_CODE_64, //!< DEV_START_CHARGING_FAILED_CODE_64
        DEV_START_CHARGING_FAILED_CODE_65, //!< DEV_START_CHARGING_FAILED_CODE_65
        DEV_START_CHARGING_FAILED_CODE_66, //!< DEV_START_CHARGING_FAILED_CODE_66
        DEV_START_CHARGING_FAILED_CODE_67, //!< DEV_START_CHARGING_FAILED_CODE_67
        DEV_START_CHARGING_FAILED_CODE_68, //!< DEV_START_CHARGING_FAILED_CODE_68
        DEV_START_CHARGING_FAILED_CODE_69, //!< DEV_START_CHARGING_FAILED_CODE_69
    };

    /*
     * 充电异常中止
     */
    enum dev_abort_charging_code {
        DEV_ABORT_CHARGING_CODE_6A = 0x6A, //!< DEV_ABORT_CHARGING_CODE_6A
        DEV_ABORT_CHARGING_CODE_6B,        //!< DEV_ABORT_CHARGING_CODE_6B
        DEV_ABORT_CHARGING_CODE_6C,        //!< DEV_ABORT_CHARGING_CODE_6C
        DEV_ABORT_CHARGING_CODE_6D,        //!< 电表通讯中断
        DEV_ABORT_CHARGING_CODE_6E,        //!< 充电异常中止，余额不足
        DEV_ABORT_CHARGING_CODE_6F,        //!< DEV_ABORT_CHARGING_CODE_6F
        DEV_ABORT_CHARGING_CODE_70,        //!< DEV_ABORT_CHARGING_CODE_70
        DEV_ABORT_CHARGING_CODE_71,        //!< DEV_ABORT_CHARGING_CODE_71
        DEV_ABORT_CHARGING_CODE_72,        //!< 急停
        DEV_ABORT_CHARGING_CODE_73,        //!< DEV_ABORT_CHARGING_CODE_73
        DEV_ABORT_CHARGING_CODE_74,        //!< 温度异常
        DEV_ABORT_CHARGING_CODE_75,        //!< DEV_ABORT_CHARGING_CODE_75
        DEV_ABORT_CHARGING_CODE_76,        //!< DEV_ABORT_CHARGING_CODE_76
        DEV_ABORT_CHARGING_CODE_77,        //!< DEV_ABORT_CHARGING_CODE_77
        DEV_ABORT_CHARGING_CODE_78,        //!< DEV_ABORT_CHARGING_CODE_78
        DEV_ABORT_CHARGING_CODE_79,        //!< DEV_ABORT_CHARGING_CODE_79
        DEV_ABORT_CHARGING_CODE_7A,        //!< DEV_ABORT_CHARGING_CODE_7A
        DEV_ABORT_CHARGING_CODE_7B,        //!< DEV_ABORT_CHARGING_CODE_7B
        DEV_ABORT_CHARGING_CODE_7C,        //!< DEV_ABORT_CHARGING_CODE_7C
        DEV_ABORT_CHARGING_CODE_7D,        //!< DEV_ABORT_CHARGING_CODE_7D
        DEV_ABORT_CHARGING_CODE_7E,        //!< DEV_ABORT_CHARGING_CODE_7E
        DEV_ABORT_CHARGING_CODE_7F,        //!< DEV_ABORT_CHARGING_CODE_7F
        DEV_ABORT_CHARGING_CODE_80,        //!< DEV_ABORT_CHARGING_CODE_80
        DEV_ABORT_CHARGING_CODE_81,        //!< DEV_ABORT_CHARGING_CODE_81
        DEV_ABORT_CHARGING_CODE_82,        //!< DEV_ABORT_CHARGING_CODE_82
        DEV_ABORT_CHARGING_CODE_83, //!< 充电桩异常中止，充电桩断电
        DEV_ABORT_CHARGING_CODE_84, //!< DEV_ABORT_CHARGING_CODE_84
        DEV_ABORT_CHARGING_CODE_85, //!< DEV_ABORT_CHARGING_CODE_85
        DEV_ABORT_CHARGING_CODE_86, //!< DEV_ABORT_CHARGING_CODE_86
        DEV_ABORT_CHARGING_CODE_87, //!< DEV_ABORT_CHARGING_CODE_87
        DEV_ABORT_CHARGING_CODE_88, //!< DEV_ABORT_CHARGING_CODE_88
        DEV_ABORT_CHARGING_CODE_89, //!< DEV_ABORT_CHARGING_CODE_89
        DEV_ABORT_CHARGING_CODE_8A, //!< DEV_ABORT_CHARGING_CODE_8A
        DEV_ABORT_CHARGING_CODE_8B, //!< DEV_ABORT_CHARGING_CODE_8B
        DEV_ABORT_CHARGING_CODE_8C, //!< DEV_ABORT_CHARGING_CODE_8C
        DEV_ABORT_CHARGING_CODE_8D, //!< DEV_ABORT_CHARGING_CODE_8D
        DEV_ABORT_CHARGING_CODE_8E, //!< DEV_ABORT_CHARGING_CODE_8E
        DEV_ABORT_CHARGING_CODE_8F, //!< DEV_ABORT_CHARGING_CODE_8F
    };

    /*
     * 未知原因停止
     */
    enum dev_other_stop_charging_code {
        DEV_OTHER_STOP_CHARGING_CODE_90 = 0x90, //!< DEV_OTHER_STOP_CHARGING_CODE_90

        DEV_ABORT_CHARGING_CODE_91, //!< 自检故障停止
        DEV_ABORT_CHARGING_CODE_92, //!< 漏电停止
        DEV_ABORT_CHARGING_CODE_93, //!< 二级过流停止
        DEV_ABORT_CHARGING_CODE_94, //!< 一级过流停止
        DEV_ABORT_CHARGING_CODE_95, //!< 接地停止
        DEV_ABORT_CHARGING_CODE_96, //!< 粘连停止
        DEV_ABORT_CHARGING_CODE_97, //!< 短路停止
        DEV_ABORT_CHARGING_CODE_98, //!< 刷卡器故障停止
        DEV_ABORT_CHARGING_CODE_99, //!< CP异常停止
        DEV_ABORT_CHARGING_CODE_9A, //!< 过压停止
        DEV_ABORT_CHARGING_CODE_9B, //!< 欠压停止
        DEV_ABORT_CHARGING_CODE_9C, //!< 电表异常停止
        DEV_ABORT_CHARGING_CODE_9D, //!< 拔枪停止
    };

    /*-------------------------------------------------------------------------------*/

    /* 充电桩登陆签到（接入认证）请求报文 */
    static ops_event_sign_in_t ops_event_sign_in[OPS_MAX_PORT_NUM];

    /* 充电桩心跳请求报文 */
    static ops_event_heartbeat_t ops_event_heartbeat[OPS_MAX_PORT_NUM];

    static ops_event_fee_mode_check_t     ops_event_check_fee;
    static ops_passive_service_fee_mode_check_t     ops_passive_check_fee;
    /* 充电桩计费策略请求报文 */
    static ops_event_fee_strategy_t ops_event_fee_strategy;

    /* 充电桩账单请求报文 */
    static ops_event_bill_t ops_event_bill[OPS_MAX_PORT_NUM];
    static ops_event_bill_t ops_event_rebill;

    /* 充电桩实时数据请求报文 */
    static ops_property_charge_data_t ops_property_charge_data[OPS_MAX_PORT_NUM];

    /* 充电桩时间同步请求报文 */
    static ops_active_service_time_syn_t ops_active_service_time_syn;

    /* 云服务器重启充电桩请求报文 */
    static ops_active_service_reboot_t ops_active_service_reboot;

    /* 云服务器启动升级请求报文 */
    static ops_active_service_start_update_t
    ops_active_service_start_update[OPS_MAX_PORT_NUM];

    /* APP启动充电请求报文 */
    static ops_active_service_start_charging_app_t
    ops_active_service_start_charging_app[OPS_MAX_PORT_NUM];

    /* APP停止充电请求报文 */
    static ops_active_service_stop_charging_app_t
    ops_active_service_stop_charging_app[OPS_MAX_PORT_NUM];

    /* 充电桩主动申请充电报文*/
    static ops_event_card_authorize_t ops_event_card_authorize[OPS_MAX_PORT_NUM];
    /* BMS各阶段上报*/
    static ops_event_charge_handshake_t       ops_event_charge_handshake[OPS_MAX_PORT_NUM];
    static ops_event_set_value_t              ops_event_set_value[OPS_MAX_PORT_NUM];
    static ops_event_charge_complete_t        ops_event_charge_complete[OPS_MAX_PORT_NUM];
    static ops_event_error_t                  ops_event_error[OPS_MAX_PORT_NUM];
    static ops_event_charge_abort_t           ops_event_charge_abort[OPS_MAX_PORT_NUM];
    static ops_event_charge_stop_t            ops_event_charge_stop[OPS_MAX_PORT_NUM];
    static ops_event_charge_output_t          ops_event_charge_output[OPS_MAX_PORT_NUM];
    static ops_event_charge_process_status_t  ops_event_charge_process_status[OPS_MAX_PORT_NUM];
    /*-------------------------------------------------------------------------------*/

    /* 云服务器登陆签到（接入认证）应答报文 */
    static ops_passive_service_sign_in_t
    ops_passive_service_sign_in[OPS_MAX_PORT_NUM];

    /* 云服务器心跳应答报文 */
    static ops_passive_service_heartbeat_t
    ops_passive_service_heartbeat[OPS_MAX_PORT_NUM];

    /* 云服务计费策略应答报文 */
    static ops_passive_service_fee_strategy_t ops_passive_service_fee_strategy;

    /* 云服务器账单应答报文 */
    static ops_passive_service_bill_t ops_passive_service_bill[OPS_MAX_PORT_NUM];

    /* 充电桩主动申请充电应答报文 */
    static ops_passive_service_card_authorize_t
    ops_passive_service_card_authorize[OPS_MAX_PORT_NUM];

    /* 云服务器时间应答报文 */
    static ops_active_service_feedback_time_syn_t
    ops_active_service_feedback_time_syn;

    /* 充电桩重启应答报文 */
    static ops_active_service_feedback_reboot_t
    ops_active_service_feedback_reboot;

    /* 充电桩启动升级应答报文 */
    static ops_active_service_feedback_start_update_t
    ops_active_service_feedback_start_update[OPS_MAX_PORT_NUM];

    /* APP启动充电应答报文 */
    static ops_active_service_feedback_start_charging_app_t
    ops_active_service_feedback_start_charging_app[OPS_MAX_PORT_NUM];

    /* APP停止充电应答报文 */
    static ops_active_service_feedback_stop_charging_app_t
    ops_active_service_feedback_stop_charging_app[OPS_MAX_PORT_NUM];

    /*-------------------------------------------------------------------------------*/

protected:
private:
    void RegisterCallback();

    static int32_t callback_active_service_start_charging_app(
        ops_active_service_start_charging_app_t *request,
        ops_active_service_feedback_start_charging_app_t *feedback);
    static int32_t callback_active_service_stop_charging_app(
        ops_active_service_stop_charging_app_t *request,
        ops_active_service_feedback_stop_charging_app_t *feedback);

    static int32_t callback_passive_service_fee_check(ops_passive_service_fee_mode_check_t *request,
            void *feedback);

    static int32_t callback_active_service_fee_strategy(
        ops_passive_service_fee_strategy_t *request,
        ops_active_service_feedback_fee_strategy_t *feedback);
    static int32_t callback_active_service_time_syn(
        ops_active_service_time_syn_t *request,
        ops_active_service_feedback_time_syn_t *feedback);
    static int32_t callback_active_service_reboot(
        ops_active_service_reboot_t *request,
        ops_active_service_feedback_reboot_t *feedback);
    static int32_t callback_active_service_start_update(
        ops_active_service_start_update_t *request,
        ops_active_service_feedback_start_update_t *feedback);
    static int32_t
    callback_passive_service_sign_in(ops_passive_service_sign_in_t *request,
                                     void *feedback);
    static int32_t
    callback_passive_service_heartbeat(ops_passive_service_heartbeat_t *request,
                                       void *feedback);
    static int32_t callbakc_passive_service_fee_strategy(
        ops_passive_service_fee_strategy_t *request, void *feedback);
    static int32_t
    callback_passive_service_bill(ops_passive_service_bill_t *request,
                                  void *feedback);
    static int32_t
    callback_passive_card_auth(ops_passive_service_card_authorize_t *request,
                               void *feedback);

signals:

public slots:

private slots:
};

#endif // OIOVCALLBACK_H
